Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datastore: fix behavior when ErrConcurrentTransaction occured #139

Merged
merged 1 commit into from
May 21, 2018

Conversation

vvakame
Copy link
Contributor

@vvakame vvakame commented May 18, 2018

#108 made ReadOnly property and previousTransaction argument.
BeginTransactionRequest.Mode's default value is BeginTransactionRequest_UNKNOWN.
But req.PreviousTransaction required BeginTransactionRequest_READ_WRITE.

This test passed before #108 . but after #108 is not.
We get API error 1 (datastore_v3: BAD_REQUEST): previous_transaction can only be set in READ_WRITE mode now.

// ErrConcurrentTransaction will be occur
err = datastore.RunInTransaction(ctx, func(txCtx1 netcontext.Context) error {
	err := datastore.Get(txCtx1, key, &Data{})
	if err != nil {
		return err
	}

	err = datastore.RunInTransaction(ctx, func(txCtx2 netcontext.Context) error {
		err := datastore.Get(txCtx2, key, &Data{})
		if err != nil {
			return err
		}

		_, err = datastore.Put(txCtx2, key, &Data{Str: "#2"})
		return err
	}, &datastore.TransactionOptions{XG: true})
	if err != nil {
		return err
	}

	_, err = datastore.Put(txCtx1, key, &Data{Str: "#1"})
	return err
}, &datastore.TransactionOptions{XG: true})
if err != datastore.ErrConcurrentTransaction {
	t.Fatal(err)
}

@vvakame
Copy link
Contributor Author

vvakame commented May 18, 2018

Travis CI failed. it was from master/HEAD.

@sbuss
Copy link
Contributor

sbuss commented May 18, 2018

Travis CI failed. it was from master/HEAD

Travis is failing due to #136, you can ignore that failure for now

@sbuss sbuss requested review from sbuss and mtraver May 18, 2018 16:34
Copy link
Contributor

@sbuss sbuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; merge pending a second lgtm

@sbuss sbuss merged commit b1f2635 into golang:master May 21, 2018
@vvakame vvakame deleted the fix-txmode branch May 24, 2018 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants